package com.itboye.mengwu.data.repository;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.reflect.TypeToken;
import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.utils.BaseErrorListener;
import com.itboye.core.utils.BaseSuccessReqListener;
import com.itboye.core.utils.ByJsonRequest.Builder;
import com.itboye.mengwu.app.ui.main.ItemFragment;
import com.itboye.mengwu.data.interfaces.IShopCar;
import com.itboye.mengwu.data.interfaces.IShopCarNext;
import com.itboye.mengwu.data.model.ShopCarNext;
import com.itboye.mengwu.data.model.ShopCarXiangQing;

public class ShopCarNextResitory extends BaseNetRepository implements
		IShopCarNext<ShopCarNext> {
	public static final String ShopCartInfo = "BY_Product_comment";// 5.9商品查询
	String api = "100";

	public ShopCarNextResitory(ICompleteListener itemFragment) {
		super(itemFragment);
	}

	@Override
	public void add(ShopCarNext model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(ShopCarNext model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(ShopCarNext model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void getInfo(ShopCarNext model) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<ShopCarNext>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> params = new HashMap<String, Object>();
//		 params.put("uid", model.getUid());
		// params.put("count", model.getCount());
		// params.put("psku_id", model.getPsku_id());
		(new Builder<ShopCarNext>())
				.setTypeVerParamsAndReturnClass(ShopCartInfo, apiVer, params,
						type)
				.requestListener(
						new BaseSuccessReqListener<ShopCarNext>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	@Override
	public List<ShopCarNext> queryYouHuiQuan(ShopCarNext model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void getShopCarXiangQing(String pid) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<ShopCarXiangQing>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("pid", pid);

		(new Builder<ShopCarXiangQing>())
				.setTypeVerParamsAndReturnClass(ShopCartInfo, apiVer, params,
						type)
				.requestListener(
						new BaseSuccessReqListener<ShopCarXiangQing>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

}
